package org.example.factory.messagequeue;

import cn.hutool.core.util.IdUtil;
import org.example.model.messagequeue.User;
import org.example.utils.RandomUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author huangy
 * @description 用户工厂
 * @since 2022/11/10 16:24
 **/
public class UserFactory {

    /*
     * @description 随机用户名
     * @author huangy
     * @since 2022/11/10 16:59
     * @param null
     * @return null
     **/
    //用户名
    public static final String[] USER_NAMES = {"123", "hy001", "hy002", "xw002", "xw003"};

    /*
     * @description 创建用户
     * @author huangy
     * @since 2022/11/10 16:53
     * @return User
     **/
    public static User createUser() {
        User user = new User();
        //雪花算法生成id
        user.setId(IdUtil.getSnowflakeNextId());
        user.setName(RandomUtils.randomChineseName());
        user.setUsername(RandomUtils.randomUsername());
        user.setPassword("123456");
        return user;
    }

    /*
     * @description 批量创建用户信息
     * @author huangy
     * @since 2023/2/8 10:47
     * @param userNum
     * @return java.util.List<User>
     **/
    public static List<User> createUsers(int userNum) {
        List<User> userList = new ArrayList<>();
        for (int i = 0; i < userNum; i++) {
            userList.add(createUser());
        }
        return userList;
    }

    private UserFactory() {
        throw new UnsupportedOperationException();
    }

}
